#pragma once

#include <sstream>
#include <iomanip>
#include <boost/static_assert.hpp>

#define kMaxLength 0x200

#define lengthof(arr) (sizeof(arr)/sizeof(arr[0]))

static long strToInt(std::stringstream stream) {
	long retn;
	stream >> retn;
	return retn;
}

static long strToInt(std::string string) {
	return strToInt(std::stringstream(string));
}

static long strToInt(const char* chars) {
	return strToInt(std::stringstream(std::string(chars)));
}

static std::stringstream intToStr(long i) {
	std::stringstream stream = std::stringstream(std::ios::in|std::ios::out);
	stream << i << std::flush;
	return stream;
}


static double strToDbl(std::stringstream stream) {
	double retn;
	stream >> retn;
	return retn;
}

static double strToDbl(std::string string) {
	return strToDbl(std::stringstream(string));
}

static double strToDbl(const char* chars) {
	return strToDbl(std::stringstream(std::string(chars)));
}

static std::stringstream dblToStr(double i, UInt8 precision = 0) {
	std::stringstream stream = std::stringstream(std::ios::in|std::ios::out);
	if ( precision > 0 )
		stream << std::ios::fixed << std::setprecision(precision);
	stream << i << std::flush;
	return stream;
}
